package ro.msg.quiz.repository;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * @author Adorjan This is quiz class.
 */
@XmlRootElement(name = "quiz")
@XmlAccessorType(XmlAccessType.PROPERTY)
public class Quiz {
	int id;
	String quizName;
	String lastEdited;
	String dateFormatString = "dd.MM.yyyy";

	/**
	 * Constructor
	 */
	public Quiz() {
		this.setId(-1);
		this.setQuizName(null);

		DateFormat dateFormat = new SimpleDateFormat(dateFormatString);
		Date date = new Date();
		this.lastEdited = dateFormat.format(date);
	}

	/**
	 * Constructor
	 * 
	 * @param id
	 *            The id of quiz.
	 * @param quizName
	 *            The name of quiz.
	 */
	public Quiz(int id, String quizName) {
		this.setId(id);
		this.setQuizName(quizName);

		DateFormat dateFormat = new SimpleDateFormat(dateFormatString);
		Date date = new Date();
		this.lastEdited = dateFormat.format(date);
	}

	/**
	 * @return Returns the id of quiz.
	 */
	// @XmlElement
	public int getId() {
		return id;
	}

	/**
	 * Sets the id of quiz.
	 * 
	 * @param id
	 *            The id of quiz to be set.
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return Returns the name of quiz.
	 */
	// @XmlElement
	public String getQuizName() {
		return quizName;
	}

	/**
	 * Sets the name of quiz.
	 * 
	 * @param quizName
	 *            The name of quiz to be set.
	 */
	public void setQuizName(String quizName) {
		this.quizName = quizName;
	}

	/**
	 * This method prints the id and name of quiz.
	 */
	@Override
	public String toString() {
		return id + " " + quizName;
	}

	/**
	 * @return Returns the last edited of quiz.
	 */
	// @XmlElement
	public String getLastEdited() {
		return lastEdited;
	}

	/**
	 * Sets the last edited of quiz.
	 * 
	 * @param lastEdited
	 *            The last edited of quiz to be set.
	 */
	public void setLastEdited(String lastEdited) {
		this.lastEdited = lastEdited;
	}
}
